﻿using System;

namespace NTLib.Core.Pool
{
    /// <summary>
    /// Managed a pool of <see cref="IPoolItem"/>.
    /// </summary>
    public interface IPool
    {
        #region Methods

        /// <summary>
        /// Gets an instance of the <see name="IPoolItem"/> Pool Item.
        /// </summary>
        /// <returns>Return a pool item type <see name="IPoolItem"/></returns>
        T Get<T>() where T : IPoolItem, new();

        /// <summary>
        /// Gets the type of the by.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        IPoolItem GetByType(Type type);

        /// <summary>
        /// Recycles the specified pool item.
        /// </summary>
        /// <param name="poolItem">The pool item.</param>
        void Recycle(IPoolItem poolItem);

        /// <summary>
        /// Destroys the specified pool item.
        /// After calling this method the instance will not be able.
        /// </summary>
        /// <param name="poolItem">The pool item.</param>
        void Destroy(IPoolItem poolItem);

        /// <summary>
        /// Cleans this instance.
        /// Depends on the algorithme's implement but this method could be used to remove surplus of items or completly reset.
        /// </summary>
        void Clean();

        #endregion
    }
}
